/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.llantas.Bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.llantas.Dao.ArticuloDaoLocal;
import mx.llantas.Dao.VendedorDaoLocal;
import mx.llantas.enumeracion.EstadoServicio;
import mx.llantas.modelo.Articulo;

/**
 *
 * @author manuel
 */
@Stateless
public class Articulobl implements ArticuloblLocal {
    @EJB
    private ArticuloDaoLocal articuloDao;
  

   @Override
   public EstadoServicio register(Articulo article) {
        if(articuloDao.findDuplicity(article)){
           return EstadoServicio.INCOMPLETE;
            //nada
        }else{
            articuloDao.create(article);
            return EstadoServicio.COMPLETE;
        }
              
    }
   @Override
   public EstadoServicio ModiFy(Articulo article) {
        
        if(article.getIdarticulo()==null||articuloDao.find(article.getIdarticulo())==null){
            return EstadoServicio.INCOMPLETE;
        }else{
        articuloDao.edit(article);
           return EstadoServicio.COMPLETE;
    }       
}
     @Override
    public EstadoServicio delete(Articulo article) {
      if(article.getIdarticulo()==null||articuloDao.find(article.getIdarticulo())==null){
            return EstadoServicio.INCOMPLETE;
        }else{
        articuloDao.remove(article);
           return EstadoServicio.COMPLETE;
    }
 }
 
       @Override
    public List<Articulo> getAll() {
        return articuloDao.findAll();
    }

    @Override
    public Articulo findById(Integer id) {
        return articuloDao.find(id);
    }

   
}


